#!/bin/bash
# This script patches all service commands into the appropriate s6- commands
# pi-hole upstream scripts need a 'service' interface. why not systemd? docker said so.
start() {
    s6-svc -wU -u -T2500 /var/run/s6/services/$service
}

stop() {
    s6-svc -wD -d -T2500 /var/run/s6/services/$service
}

restart() {
    stop
    start
    #s6-svc -t -wR -T5000 /var/run/s6/services/$service
}

status() {
    s6-svstat /var/run/s6/services/$service
}

service="$1"
command="$2"

if [[ ! -d "/var/run/s6/services/$service" ]] ; then
    echo "s6 service not found for $service, exiting..."
    exit
fi;

${command} "${service}"
